#coding=utf-8
'''
Created on 2013-9-10

@author: Ben

祭祀
'''

from ..common import Command, Logger, RequestModel
from ..common.SocketService import gameSocketService
import ResourceData

'''
获取祭祀信息
'''
class WorshipGetInfoRequest(RequestModel.RequestModel):
    
    def setCommand(self):
        self.command = Command.GET_WORSHIP_INFO
        
    def onReceive(self, data):
        ResourceData.updateWorship(data)
    
'''
免费祭祀
'''
def worship(godId):
    command = Command.WORSHIP
    params = 'godId=' + str(godId)
    gameSocketService.send(command, params, worshipCallback)
    
'''
免费祭祀回调函数
'''
def worshipCallback(data):
    if 'resourceGot' in data:
        if 'addNum' in data['resourceGot'][0] and 'resourceType' in data['resourceGot'][0]:
            print u'虔诚祭祀'
            Logger.log('祭祀获得资源, type:' + str(data['resourceGot'][0]['resourceType'])\
                        + ', num:' + str(data['resourceGot'][0]['addNum']))